package com.sv.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.sv.base.repository.BaseRepository;

public class SqlMapClientFactory {

    @Autowired
    @Qualifier("sqlMapClient")
    private static SqlMapClient sqlMapClient;
    
    public static SqlMapClient getSqlMapClient() {
        
        if(null == sqlMapClient){
            WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
            sqlMapClient = wac.getBean("sqlMapCilent", SqlMapClient.class);
        }
        
        return sqlMapClient;
    }

    public void setSqlMapClient(SqlMapClient sqlMapClient) {
        SqlMapClientFactory.sqlMapClient = sqlMapClient;
    }
    
}
